package com.dg.gallery

import com.db.gallery.Project
import com.db.gallery.ProjectGroup

class GalleryProjectGroup {
	
	List<List<Project>> projectRows = null
	ProjectGroup projectGroup = null
	
	GalleryProjectGroup(ProjectGroup aProjectGroup) {
		projectGroup = aProjectGroup
		projectRows = []
		
		def projects = projectGroup.projects
		
		List<Project> row = []
		def columnCount = 0
		
		for (Project project in projects) {
			++columnCount
			
			if (columnCount > 4) {
				projectRows.add(row)
				row = []
				columnCount = 1
			}
			
			row.add(project)
		}
		
		if (columnCount <= 4) {
			projectRows.add(row)
		}
	}

}
